package com.yimi.yinhepda.views.offline.unload;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.pda.ym.base.BaseActivity;
import com.pda.ym.base.BaseTitleActivity;
import com.yimi.yinhepda.R;
import com.yimi.yinhepda.db.table.UnloadTaskTable;
import com.pda.ym.utils.FastClick;

import org.jetbrains.annotations.NotNull;

/**
 * 离线卸车成功界面.
 *
 * @author lj
 */
public class OffLineUnloadSuccessActivity extends BaseTitleActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        EditText etStowageNo = findViewById(R.id.et_stowageNo);
        EditText etTaskNo = findViewById(R.id.et_taskNo);
        Button btnCarPlate = findViewById(R.id.btn_carPlate);
        EditText etCarNo = findViewById(R.id.et_carNo);
        EditText etSrcDept = findViewById(R.id.et_src_dept);
        TextView tvDestDept = findViewById(R.id.tv_dest_dept);
        EditText etPiaoNum = findViewById(R.id.et_piaoNum);
        TextView etJianNum = findViewById(R.id.et_jianNum);
        findViewById(R.id.btn_sure).setOnClickListener(this);

        UnloadTaskTable taskTable = (UnloadTaskTable) getIntent().getSerializableExtra("taskTable");
        etStowageNo.setText(taskTable.getStowageNo());
        etTaskNo.setText(taskTable.getTask());
        String carNo = taskTable.getCarNo();
        btnCarPlate.setText(carNo.substring(0, 1));
        etCarNo.setText(carNo.substring(1, carNo.length()));
        etSrcDept.setText(taskTable.getSrcDeptName());
        tvDestDept.setText(taskTable.getDestDeptName());
        etPiaoNum.setText(taskTable.getPriceNum() + "");
        etJianNum.setText(taskTable.getPiecesNum() + "");
    }

    @Override
    public String getPageName() {
        return "卸车成功";
    }

    @Override
    public void onClick(View v) {
        if (FastClick.isFastClick()) {
            return;
        }
        switch (v.getId()) {
            case R.id.btn_sure:
                //上传离线卸车数据
                OffLineUnLoadUtil.uploadOfflineLoadData();
                //确定按钮
                finish();
                break;
            default:
                break;
        }
    }

    @Override
    public boolean showBack() {
        return false;
    }

    @Override
    public void setBack() {

    }

    @NotNull
    @Override
    public String setTitle() {
        return getPageName();
    }

    @Override
    public int setContentViewId() {
        return R.layout.activity_offline_unload_success;
    }
}
